<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>定时任务日志</title>
</head>
<style>
    *{font-size: 12px;}
    td img {width:80px; height:80px}
    table tr th {border-bottom: 1px solid #aaaaaa; background: #eeeeee; min-width: 85px;}
    table tr td {border-bottom: 1px solid #cccccc; min-width: 85px;}
</style>

<body th:with="nowDate=${#dates.format(new java.util.Date().getTime(), 'yyyy-MM-dd')}">
<form th:method="get" th:each="data: ${jobLogPage}">
    <div th:with="pages = ${(data.total+data.size-1)/data.size}">
        <span>总数：[[${data.total}]]条，共[[${pages}]]页&nbsp;&nbsp;</span>
        <span th:if="${data.current>1}">
            <a href="javascript:void(0);" th:onclick="pageClick([[${data.current}-1]], [[${data.size}]]);">上一页</a>
        </span>
        <span th:if="${data.current<=1}">上一页</span>
        <span th:if="${data.current< pages}">
            <a href="javascript:void(0);" th:onclick="pageClick([[${data.current}+1]], [[${data.size}]]);">下一页</a>
        </span>
        <span th:if="${data.current>=pages}">下一页</span>
        <span th:if="${data.current>1}">
            <a href="javascript:void(0);" th:onclick="pageClick(1, [[${data.size}]]);">首页</a>
        </span>
        <span th:if="${data.current<pages}">
            <a href="javascript:void(0);" th:onclick="pageClick([[${pages}]], [[${data.size}]]);">尾页</a>
        </span>
        <span>第[[${data.current}]]页</span>
    </div>
</form>

<table>
    <thead>
        <tr>
            <th th:text="序号">count</th>
            <th th:text="日志Id">logId</th>
            <th th:text="任务ID">jobId</th>
            <th th:text="任务名">jobName</th>
            <th th:text="类路径">className</th>
            <th th:text="方法">method</th>
            <th th:text="参数">params</th>
            <th th:text="cron表达式">cron</th>
            <th th:text="执行类型">execType</th>
            <th th:text="执行结果">execStatus</th>
            <th th:text="执行开始时间">created</th>
            <th th:text="执行结束时间">updated</th>
        </tr>

    </thead>
    <tbody>
        <tr th:each="baseJobLog,iterStat: ${jobLogPage.records}"  th:class="${iterStat.odd}? 'odd':'even'">
            <td th:text="${iterStat.count}">count</td>
            <td th:text="${baseJobLog.logId}">logId</td>
            <td th:text="${baseJobLog.jobId}">jobId</td>
            <td th:text="${baseJobLog.jobName}">jobName</td>
            <td th:text="${baseJobLog.className}">className</td>
            <td th:text="${baseJobLog.method}">method</td>
            <td th:text="${baseJobLog.params}">params</td>
            <td th:text="${baseJobLog.cron}">cron</td>
            <td>
                <span th:if="${baseJobLog.execType} eq 1" th:text="自动">execType</span>
                <span th:if="${baseJobLog.execType} eq 2" th:text="手动">execType</span>
            </td>
            <td>
                <span th:if="${baseJobLog.execStatus} eq 1" th:text="成功">execStatus</span>
                <span th:if="${baseJobLog.execStatus} eq 0">
                    <a th:href="@{/getJobLogDetail(logId=${baseJobLog.logId})}" target="_self">失败</a>
                </span>
            </td>
            <td th:text="${baseJobLog.created}">created</td>
            <td th:text="${baseJobLog.updated}">updated</td>
        </tr>
    </tbody>
</table>
</body>
<script type="text/javascript" th:inline="javascript">
    /*<![CDATA[*/
    var xmlHttp;
    var pageClickUrl = /*[[@{/getJobLogPage}]]*/ null;
    var jobIdObj = [[${param.jobId}]]||[""];
    var jobId = jobIdObj[0];

    var pageClick = function (pageNo, pageSize) {
        xmlHttp = new XMLHttpRequest();
        xmlHttp.onreadystatechange = function() {pageClickCallback()};
        xmlHttp.open("GET", pageClickUrl+"?jobId="+jobId+"&current="+pageNo+"&size="+pageSize, true);
        xmlHttp.send();
    }

    var pageClickCallback = function() {
        if (xmlHttp.readyState==4) {
            if (xmlHttp.status == 200) {
                var res = xmlHttp.responseText;
                document.body.innerHTML = null;
                document.write(res);
            }
        }
    }
    /*]]>*/
</script>
</html>
